const express = require('express')
const router = express.Router()
const path = require('path')
const { send } = require('process')


// 获取验证模块
// const authorization = require(path.join(process.cwd(), '/modules/authorization'))
const rightService = require(path.join(process.cwd(), '/services/RightService'))

// 获取权限列表
router.get('/:type', function (req, res) {
    if (!req.params.type) return res.sendResult(null, 400, "显示类型未定义")
    if (req.params.type !== 'list' && req.params.type !== 'tree') return res.sendResult(null, 400, '显示类型参数错误')

    rightService.getAllRights(req.params.type, (err, rights) => {
        if(err) return res.sendResult(null,400,err)
		res.sendResult(rights,200,"获取权限列表成功")
    })
})

module.exports =  router